package com.simple.datax.bo.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.simple.datax.bo.IDataxEnterpriseChannelBO;
import com.simple.datax.dao.IDataxEnterpriseChannelDAO;
import com.simple.datax.vo.DataxEnterpriseChannelIdVO;
import com.simple.datax.vo.DataxEnterpriseChannelVO;
import com.simple.datax.vo.EnterpriseChannelDetailVO;
import com.simple.util.object.PageInfoBean;

@Service("dataxEnterpriseChannelBO")
@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
public class DataxEnterpriseChannelBOImpl implements IDataxEnterpriseChannelBO {

	@Autowired
	private IDataxEnterpriseChannelDAO dataxEnterpriseChannelDAO;
	
	@Override
	public DataxEnterpriseChannelVO findById(DataxEnterpriseChannelIdVO id) {
		return dataxEnterpriseChannelDAO.findById(id);
	}

	@Override
	public List<DataxEnterpriseChannelVO> findAll() {
		return dataxEnterpriseChannelDAO.findAll();
	}
	
	@Override
	public List<EnterpriseChannelDetailVO> findAllDetailByPage(String entCode,String entName,PageInfoBean pageInfoBean){
		return dataxEnterpriseChannelDAO.findAllDetailByPage(entCode, entName, pageInfoBean);
	}

	@Override
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false,rollbackFor={Exception.class})
	public void add(DataxEnterpriseChannelVO dataxEnterpriseChannelVO) {
		dataxEnterpriseChannelDAO.saveOrUpdate(dataxEnterpriseChannelVO);
	}
	
	@Override
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false,rollbackFor={Exception.class})
	public void edit(DataxEnterpriseChannelVO dataxEnterpriseChannelVO) {
		DataxEnterpriseChannelVO dataxEnterpriseChannelVOTmp = dataxEnterpriseChannelDAO.findById(dataxEnterpriseChannelVO.getId());
		dataxEnterpriseChannelVOTmp.setFiFlag(dataxEnterpriseChannelVO.getFiFlag());
		dataxEnterpriseChannelVOTmp.setFiSysReceiveId(dataxEnterpriseChannelVO.getFiSysReceiveId());
		dataxEnterpriseChannelVOTmp.setFiSysSendId(dataxEnterpriseChannelVO.getFiSysSendId());
		dataxEnterpriseChannelDAO.update(dataxEnterpriseChannelVOTmp);	
	}

	@Override
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false,rollbackFor={Exception.class})
	public void del(DataxEnterpriseChannelIdVO dataxEnterpriseChannelIdVO) {
		dataxEnterpriseChannelDAO.delete(dataxEnterpriseChannelIdVO);
	}

}
